home *** CD-ROM | disk | FTP | other *** search
/ The Big Day - Work Smarter - Learn How / The Big Day - Work Smarter - Learn How (Microsoft).BIN / Trivia_files / script.js < prev    next >
Text File  |  2001-02-06  |  31KB  |  1,120 lines

  1.  
  2. function LoadSld( slideId )
  3. {
  4.     if( !g_supportsPPTHTML ) return
  5.     if( slideId )
  6.         parent.SldUpdated(slideId)
  7.     g_origSz=parseInt(SlideObj.style.fontSize)
  8.     g_origH=SlideObj.style.posHeight
  9.     g_origW=SlideObj.style.posWidth
  10.     g_scaleHyperlinks=(document.all.tags("AREA").length>0)
  11.     if( g_scaleHyperlinks )
  12.         InitHLinkArray()
  13.     if( g_scaleInFrame||(IsWin("PPTSld") && parent.IsFullScrMode() ) )
  14.         document.body.scroll="no"
  15.     _RSW()
  16.     if( IsWin("PPTSld") && parent.IsFullScrMode() )    {
  17.         document.oncontextmenu=parent._CM;
  18.         self.focus()
  19.     }
  20. }
  21. function MakeSldVis( fTrans ) 
  22. {
  23.     fTrans=fTrans && g_showAnimation
  24.     if( fTrans )
  25.     {
  26.         if( g_bgSound ) {
  27.             idx=g_bgSound.indexOf(",");
  28.             pptSound.src=g_bgSound.substr( 0, idx );
  29.             pptSound.loop= -(parseInt(g_bgSound.substr(idx+1)));
  30.         }
  31.         SlideObj.filters.revealtrans.Apply()
  32.     }
  33.     SlideObj.style.visibility="visible"
  34.     if( fTrans )
  35.         SlideObj.filters.revealtrans.Play()
  36. }
  37. function MakeNotesVis() 
  38. {
  39.     if( !IsNts() ) return false 
  40.     SlideObj.style.display="none"
  41.     nObj = document.all.item("NotesObj")
  42.     parent.SetHasNts(0)
  43.     if( nObj ) { 
  44.         nObj.style.display=""
  45.         parent.SetHasNts(1)
  46.     }
  47.     return 1
  48. }
  49. function Redirect( frmId,sId )
  50. {
  51.     var str=document.location.hash,idx=str.indexOf('#')
  52.     if(idx>=0) str=str.substr(1);
  53.     if( window.name != frmId && ( sId != str) ) {
  54.         obj = document.all.item("Main-File")
  55.         window.location.href=obj.href+"#"+sId
  56.         return 1
  57.     }
  58.     return 0
  59. }
  60. function HideMenu() { if( frames["PPTSld"] && PPTSld.document.all.item("ctxtmenu") && PPTSld.ctxtmenu.style.display!="none" ) { PPTSld.ctxtmenu.style.display='none'; return true } return false }
  61. function IsWin( name ) { return window.name == name }
  62. function IsNts() { return IsWin("PPTNts") }
  63. function IsSldOrNts() { return( IsWin("PPTSld")||IsWin("PPTNts") ) }
  64. function SupportsPPTAnimation() { return( navigator.platform == "Win32" && navigator.appVersion.indexOf("Windows")>0 ) }
  65. function SupportsPPTHTML()
  66. {
  67.     var appVer=navigator.appVersion, msie=appVer.indexOf("MSIE "), ver=0
  68.     if( msie >= 0 )
  69.         ver=parseFloat( appVer.substring( msie+5, appVer.indexOf(";",msie) ) )
  70.     else
  71.         ver=parseInt(appVer)
  72.  
  73.     return( ver >= 4 && msie >= 0 )
  74. }
  75. var MHTMLPrefix = CalculateMHTMLPrefix(); 
  76. function CalculateMHTMLPrefix()
  77. {
  78.     if ( document.location.protocol == 'mhtml:') { 
  79.         href=new String(document.location.href) 
  80.         Start=href.indexOf('!')+1 
  81.         End=href.lastIndexOf('/')+1 
  82.         if (End < Start) 
  83.             return href.substring(0, Start) 
  84.         else 
  85.         return href.substring(0, End) 
  86.     }
  87.     return '';
  88. }
  89.  
  90. function _RSW()
  91. {
  92.     if( !g_supportsPPTHTML || IsNts() ||
  93.       ( !g_scaleInFrame && (( window.name != "PPTSld" ) || !parent.IsFullScrMode()) ) )
  94.         return
  95.  
  96.     cltWidth=document.body.clientWidth
  97.     cltHeight=document.body.clientHeight
  98.     factor=(1.0*cltWidth)/g_origW
  99.     if( cltHeight < g_origH*factor )
  100.         factor=(1.0*cltHeight)/g_origH
  101.  
  102.     newSize = g_origSz * factor
  103.     if( newSize < 1 ) newSize=1
  104.  
  105.     s=SlideObj.style
  106.     s.fontSize=newSize+"px"
  107.     s.posWidth=g_origW*factor
  108.     s.posHeight=g_origH*factor
  109.     s.posLeft=(cltWidth-s.posWidth)/2
  110.     s.posTop=(cltHeight-s.posHeight)/2
  111.  
  112.     if( g_scaleHyperlinks )
  113.         ScaleHyperlinks( factor )
  114. }
  115.  
  116. function _KPH()
  117.   if( IsNts() ) return;
  118.  
  119.   if( !parent.IsFramesMode() && event.keyCode == 27 && !parent.HideMenu() )
  120.     parent.window.close( self );
  121.   else if( event.keyCode == 32 )
  122.   {
  123.     if( window.name == "PPTSld" )
  124.       parent.PPTSld.DocumentOnClick();
  125.     else
  126.       parent.GoToNextSld();
  127.   }
  128. }
  129.  
  130. function PlaySound( href, loop ){
  131.     href= unescape(href);
  132.     if( window.event ) window.event.cancelBubble = true;
  133.     pptSound.src = href;
  134.     pptSound.loop = loop ? -1 : 0;
  135. }
  136. var AE_NONE = 0, AE_DIM = 1, AE_HIDE = 2, AE_HIDEIMDTLY = 3, LONG_INTERVAL = 10, SHORT_INTERVAL = 5, g_curAnim = null, g_vml = 0;
  137. function ParseAnimations(){
  138.     nr = document.all.tags("DIV").length;
  139.     while(nr > 0) {
  140.         rObj = document.all.tags("DIV").item(--nr);
  141.         if(rObj.style.cssText != null) {
  142.             build = rObj.style.cssText.indexOf("mso-build");
  143.             if(build >= 0)
  144.                 AddAnimation(rObj);
  145.         }
  146.     }
  147.     if(g_autoTrans){
  148.         totT=0, autoAnims=0;
  149.         rAnims=g_animManager.m_anims;
  150.         nBuilds=g_animManager.m_numBuilds;
  151.         for(x=nBuilds;x>0;x--)
  152.         if(-1 != rAnims[x].m_secs){
  153.             totT+=rAnims[x].m_secs;
  154.             autoAnims++;
  155.         }
  156.         time=g_transSecs-totT;
  157.         if(time<0) time=0;
  158.         time=time/(nBuilds-autoAnims+1);
  159.         for(x=nBuilds;x>0;x--)
  160.             if(-1 == rAnims[x].m_secs)
  161.                 rAnims[x].m_secs=time;
  162.     }
  163. }
  164. function AddAnimation(rObj){
  165.     a =new Animation();
  166.     a.m_obj =rObj;
  167.     a.m_oldc =rObj.color;
  168.     GetVal=rObj.style.getAttribute;
  169.     var t;
  170.     if( t=GetVal("mso-build") ) a.m_build=t-0;
  171.     if( t=GetVal("mso-build-after-action") ) a.m_aAct=t-0;
  172.     if( t=GetVal("mso-build-after-color") ) a.m_oldc=t;
  173.     if( t=GetVal("mso-build-auto-secs") ) a.m_secs=t-0;
  174.     if( t=GetVal("mso-build-avi") ) a.m_video=t;
  175.     if( t=GetVal("mso-build-dual-id") ) a.m_dId=t;
  176.     if( t=GetVal("mso-build-order") ) a.m_order=t-0;
  177.     if( t=GetVal("mso-build-sound-name") ) a.m_sound=t;
  178.  
  179.     g_animManager.AddAnimation(a);
  180. }
  181. function ShowVGXObj(rObj){
  182.     vmlId=null,ImgTag=null;
  183.     curObj=rObj;
  184.     sObj =document.all.item("SlideObj");
  185.     while(null == ImgTag && null != curObj && sObj != curObj){
  186.         ImgTag =curObj.children.tags("IMG").item(0);
  187.         curObj =(curObj.parentElement.tagName == "DIV") ? curObj.parentElement : null
  188.     }
  189.     if(null !=ImgTag)
  190.         vmlId =ImgTag.getAttribute("v:shapes");
  191.     if(null !=vmlId) {
  192.         idx =vmlId.indexOf(",");
  193.         if(idx > 0) vmlId =vmlId.substr(0, idx);
  194.         vgxObj =document.all.item(vmlId);
  195.         if((null != vgxObj) && (null != vgxObj.parentElement) && (vgxObj.parentElement.style.display != "none")){
  196.             vgxObj.parentElement.style.visibility = "visible";
  197.             ImgTag.style.visibility = "hidden";
  198.         }
  199.         else
  200.             rObj.style.visibility = "visible";
  201.     }
  202. }
  203. function AnimationManager(){
  204.     t=this;
  205.     t.m_anims=new Array();
  206.     t.m_numBuilds=0;
  207.     t.m_activeObj=null;
  208.     t.m_curBuild=1;
  209.     t.m_timer=-1;
  210.     t.m_objToHide=null;
  211.     t.m_objToDim=null;
  212.     t.m_colorToDim=-1;
  213.     t.m_isPlaying=0;
  214.     t.m_autoTimer=-1;
  215.     t.Peek=AM_Peek;
  216.     t.Next=AM_Next;
  217.     t.Previous=AM_Previous;
  218.     t.AddAnimation=AM_AddAnimation;
  219.     t.ShowShapes=AM_ShowShapes;
  220.     t.Swap=AM_Swap;
  221. }
  222. function AM_ShowShapes(){
  223.     for(x=this.m_numBuilds; x>0; x--){
  224.         if(g_vml)
  225.             ShowVGXObj(this.m_anims[x].m_obj);
  226.         aObj =this.m_anims[x].m_obj;
  227.         if(aObj)
  228.             aObj.style.visibility = "visible";
  229.     }
  230.     this.m_numBuilds =0;
  231. }
  232. function AM_Swap(cur){
  233.     rList =this.m_anims;
  234.     t =rList[cur+1];
  235.     rList[cur+1] =rList[cur];
  236.     rList[cur] =t;
  237. }
  238. function AM_AddAnimation(a){
  239.     this.m_anims[++this.m_numBuilds] = a;
  240.     this.m_curBuild =this.m_numBuilds;
  241.     cur =this.m_numBuilds;
  242.     if(a.m_order > 0){
  243.         while(cur-- > 1 && Math.abs(this.m_anims[cur+1].m_order) > Math.abs(this.m_anims[cur].m_order))
  244.             this.Swap(cur);
  245.     }
  246.     else {
  247.         while(cur-- > 1 && Math.abs(this.m_anims[cur+1].m_order) >= Math.abs(this.m_anims[cur].m_order))
  248.             this.Swap(cur);
  249.     }
  250. }
  251. function AM_Peek(){
  252.     if(g_animManager.m_curBuild > 0 && 0 < g_animManager.m_numBuilds) {
  253.         secs =g_animManager.m_anims[g_animManager.m_curBuild].m_secs;
  254.         if(secs != -1)
  255.             g_animManager.m_autoTimer = window.setTimeout("_DocAction()", secs);
  256.     }
  257.     else if(1 == g_autoTrans && IsWin("PPTSld") && !parent.IsFramesMode()){
  258.         setTimeout("parent.GoToNextSld()", g_transSecs);
  259.     }
  260. }
  261. function AM_Next(){
  262.     if(0 == this.m_numBuilds || (g_curAnim != null)) return 0; 
  263.     success=0;
  264.     if(this.m_autoTimer != -1)
  265.         window.clearTimeout(this.m_autoTimer);
  266.     if(this.m_objToHide != null)
  267.         this.m_objToHide.style.visibility = "hidden";
  268.     if(this.m_objToDim != null) {
  269.         nr = document.all.length;
  270.         while(nr-- > 0) {
  271.             rObj =document.all.item(nr);
  272.             if(this.m_objToDim.contains(rObj))
  273.                 rObj.style.color = this.m_colorToDim;
  274.         }
  275.     }
  276.     if(this.m_curBuild > 0) {
  277.         this.m_activeObj =this.m_anims[this.m_curBuild--];
  278.         this.m_activeObj.Start();
  279.         success =1;
  280.     }
  281.     return success;
  282. }
  283. function AM_Previous(){
  284.     if((null == g_curAnim) && (this.m_curBuild <= this.m_numBuilds)) {
  285.         this.m_curBuild++;
  286.         var animObj = this.m_anims[this.m_curBuild];
  287.         if(this.m_curBuild >= 1)
  288.             animObj.m_obj.style.vi